const fs = require("fs");
const path = require("path");
const express = require("express");
const router = express.Router();

let apis = [];
// 忽略的文件
const ignoreFiles = ["index.js", "common.js"];

fs.readdirSync(__dirname)
  .filter(function (filename) {
    return !ignoreFiles.includes(filename) && filename.slice(-3) === ".js";
  })
  .forEach(function (filename) {
    let filepath = path.join(__dirname, filename);
    apis.push(require(filepath));
  });

router.use("/", apis);
module.exports = router;
